package com.blunka.framework.client.ui.tools;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.blunka.framework.client.enums.ModelType;

/**
 * 按钮事件
 * @author Administrator
 *
 */
public class MenuAction {

	/**
	 * 创建建模节点
	 * @return
	 */
	public static ActionListener createBlkModel(String title,ModelType modelType){
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent event) {
				ActionUtils.createBlkModel(title, modelType);
			}

		};

		return action;
	}

	/**
	 * 创建zi
	 * @param title
	 * @param modelType
	 * @return
	 */
	public static ActionListener createTableOrViewBlkModel(String title,ModelType modelType){
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent event) {
				ActionUtils.createTableOrView(title, modelType);
			}
		};
		return action;
	}

	/**
	 * 创建新字段
	 * @param title
	 * @param modelType
	 * @return
	 */
	public static ActionListener createFieldAttr(String title,ModelType modelType){
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent event) {
				ActionUtils.createField(title, modelType);
			}
		};
		return action;
	}

	/**
	 * 修改字段属性
	 * @param title
	 * @param modelType
	 * @return
	 */
	public static ActionListener modifyFieldAttr(String title,ModelType modelType){
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent event) {
				ActionUtils.modifyField(title, modelType);
			}
		};
		return action;
	}

	/**
	 * 删除节点
	 * @return
	 */
	public static ActionListener delModelNode(){
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.delNode();
			}
		};

		return action;
	}
	
	/**
	 * 复制选中表或者试图所有子节点
	 * @return
	 */
	public static ActionListener copyChildModelNode() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.copyChildModelNode();
			}
		};

		return action;
	}
	
	/**
	 * 复制选址属性节点
	 * @return
	 */
	public static ActionListener copyModelNode() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.copyModelNode();
			}
		};

		return action;
	}
	
	/**
	 * 粘贴复制的节点
	 * @return
	 */
	public static ActionListener pasteModelNodes() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.pasteModelNodes();
			}
		};

		return action;
	}
	
	/**
	 * 节点置new
	 * @return
	 */
	public static ActionListener modelNodeNew() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.pasteModelNodesNew();
			}
		};

		return action;
	}
	
	/**
	 * 节点置changed
	 * @return
	 */
	public static ActionListener modelNodeChanged() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.pasteModelNodesChanged();
			}
		};

		return action;
	}
	
	/**
	 * 导出
	 * @return
	 */
	public static ActionListener impNode() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.pasteImportNodes();
			}
		};

		return action;
	}
	
	/**
	 * 导出
	 * @return
	 */
	public static ActionListener expNode() {
		ActionListener action = new ActionListener(){
			@Override
			public void actionPerformed(ActionEvent arg0) {

				ActionUtils.parseExpNode();
			}
		};

		return action;
	}
}
